﻿#*******************************************************************************
#
#	RECT
#
#*******************************************************************************

class Rect:
	def __init__(self,x,y,w,h):
	#x1,y1 = top left corner x2,y2=bottom right corner
		self.x1=x
		self.x2=x+w
		self.y1=y
		self.y2=y+h
	
	def center(self):
		center_x = (self.x1 + self.x2) / 2
		center_y = (self.y1 + self.y2) / 2
		return (center_x, center_y)
	
	def intersect(self,other):
	#a room must be 2 cases away from an other
		return (self.x1 <= other.x2+2 and self.x2 >= other.x1-2 and
				self.y1 <= other.y2+2 and self.y2 >= other.y1-2)